/*
 * @Description: 
 * @Version: 2.0
 * @Autor: wsh
 * @Date: 2023-06-20 18:06:22
 * @LastEditors: wsh
 * @LastEditTime: 2023-06-26 14:39:39
 */
// 列表
const tableConfig = {
  stripe: true,
  border: true,
  maxHeight: '80vh',
  columns: [
    { label: '养老机构', prop: 'organizationName' },
    { label: '老人姓名', prop: 'oldmanName' },
    { label: '老人身份证号', prop: 'idCard', plusXing: '', },
    { label: '老人联系方式', prop: 'oldmanPhone' },
    { label: '退院时间', prop: 'checkoutDate' },
    { label: '退院原因', prop: 'checkoutReason' },
    { label: '办理人', prop: 'transactorName' },
    { label: '办理时间', prop: 'transactDate' },
    { label: '备注', prop: 'checkoutNote' },
    {
      label: '操作',
      prop: 'menu',
      width: 300,
      fixed: 'right'
    }
  ]
}

// 详情
export const detailConfig = {
  inline: false,
  showBtn: false,
  labelPosition: 'left',
  column: [
    { label: '养老机构', prop: 'organizationName', span: 8 },
    { label: '老人姓名', prop: 'oldmanName', span: 8 },
    { label: '老人身份证号', prop: 'idCard', span: 8 },
    { label: '老人联系方式', prop: 'oldmanPhone', span: 8 },
    { label: '退院时间', prop: 'checkoutDate', span: 8 },
    { label: '退院原因', prop: 'checkoutReason', span: 8 },
    { label: '办理人', prop: 'transactorName', span: 8 },
    { label: '办理时间', prop: 'transactDate', span: 8 },
    { label: '备注', prop: 'checkoutNote', span: 24 },
  ]
}

export const baseConfig = {
  pageName: '老人退院管理',
  // 数据字典
  dictcodes: [],
  rowKey: 'idCard',
  api: {
    index: 'view_dpElderlyCheckoutRecord_page',
  },
  auth: {
    index: 'view_dpElderlyCheckoutRecord_page',
    // 批量搜索
    mulitSet: 'mulitSet'
  },
  // 当前行操作按钮
  menuBtn: [
    {
      icon: 'detail',
      label: '查看',
      type: 'primary',
      operate: 'detail',
      auth: 'view_dpElderlyCheckoutRecord_page',
      text: true,
      show: true
    },
  ],
  dialogConfig: {
    width: '80%'
  },
  // 搜索
  searchConfig: {
    inline: true,
    showBtn: true,
    labelPosition: 'left',
    column: [
      { label: '养老机构', prop: 'organizationName', span: 6 },
      { label: '老人姓名', prop: 'oldmanName', span: 6 },
      { label: '老人身份证号', prop: 'idCard', span: 6 },
      { label: '老人联系方式', prop: 'oldmanPhone', span: 6 },
      {
        label: '退院时间', prop: 'checkoutDateBetween', type: 'daterange',
        format: 'YYYY年MM月DD日',
        valueFormat: 'YYYY-MM-DD', span: 6
      },
      { label: '办理人', prop: 'transactorName', span: 6 },
      {
        label: '办理时间', prop: 'transactDateBetween', type: 'daterange',
        format: 'YYYY年MM月DD日',
        valueFormat: 'YYYY-MM-DD', span: 6
      },
    ]
  },
  // 列表
  tableConfig,
  // 详情
  detailConfig,
  beforeOnLoadFormate: (query) => {
    console.log(query, 'beforeOnLoadFormate');
    return new Promise((resolve, reject) => {
      console.log(query, 'Promise');
      if (query.hasOwnProperty('checkoutDateBetween')) {
        const values = Object.values(query.checkoutDateBetween)
        query.checkoutDateBetween = values.join(',')
      }
      if (query.hasOwnProperty('transactDateBetween')) {
        const values = Object.values(query.transactDateBetween)
        query.transactDateBetween = values.join(',')
      }
      resolve({
        ...query,
      })
    })
  },
}